<?php

namespace App\Providers;

use Illuminate\Support\Facades\Config;
use Illuminate\Support\ServiceProvider;
use DB;
use Log;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        // 监听数据库操作事件
        if(env('DB_LISTEN') == true){
            DB::listen(function($sql,$bindings,$time) {
                Log::info('['.$time.'][sql]['.$sql.']  with:{'.join(',',$bindings).'}');
            });
        }
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
